package fr.lox.fall.main;

import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;

import fr.lox.fall.common.HUD;
import fr.lox.fall.common.Map;
import fr.lox.fall.common.Player;

public class game implements ApplicationListener {
	private SpriteBatch batch;
	private BitmapFont font;
	private float w;
	private float h;
	private Player p;
	private Map mp;
	private HUD hud;
	
	@Override
	public void create() {		
		 w = Gdx.graphics.getWidth();
		 h = Gdx.graphics.getHeight();
		 FreeTypeFontGenerator gen = 
				 new FreeTypeFontGenerator(
						 Gdx.files.internal("fonts/nono.ttf"));
		 
		 
		 this.font=gen.generateFont(20);
		
		p = new Player(20f);
		mp = new Map();
		Gdx.input.setInputProcessor(p);
		batch = new SpriteBatch();
		hud = new HUD();
		
	}

	@Override
	public void dispose() {
		batch.dispose();
		p.dispose();
	}

	@Override
	public void render() {		
		Gdx.gl.glClearColor(1, 1, 1, 1);
		Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

		batch.begin();
		mp.update(p);
		mp.draw(batch);
		p.update();
		hud.update();
		p.draw(batch);
		hud.draw(batch);
		font.draw(batch, Long.toString(p.getScore()), 220, 1000);
		batch.end();
	}

	@Override
	public void resize(int width, int height) {
		p.resize(width, height);
		this.mp.resize(width, height);
	}

	@Override
	public void pause() {
	}

	@Override
	public void resume() {
	}
}
